<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>usersInfo.jsp</title>
	<base href="<%=basePath%>">
	<link rel="stylesheet" type="text/css" href="js/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="js/themes/default/combobox.css">
	<link rel="stylesheet" type="text/css" href="js/themes/icon.css">
	<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="js/jquery.easyui.min-1.2.0.js"></script>
	<script type="text/javascript" src="js/easyDemo.js"></script>
	<script>
		$(function(){
			$('#test').datagrid({
				title:'用户管理',
				iconCls:'icon-edit',
				width: 700,  
		        height: 'auto',  
		        nowrap: false,  
		        striped: true,  
		        border: true,  
		        collapsible:false,//是否可折叠的  
		        fit: true,//自动大小 
		        remoteSort:false, 
		        //AllowPaging:true,  
		        //OnPageIndexChanged:ChangePage,        
		        singleSelect:false,//是否单选  
		        pagination:true,//分页控件  
		        rownumbers:true,//行号  
				url:'userInfo.action',//数据源
				loadMsg:'数据装载中......',
				idField:'id',  
		        sortName:'id',
				frozenColumns:[[
	                {field:'ck',checkbox:true},
	                {title:'ID',field:'id',width:40,align:'center',sortable:true}
				]],
				columns:[[
			         //{title:'ID',field:'id',width:'140'},
			     	 {title:'姓名',field:'name',width:'60',align:'center'},
			     	 {title:'角色',field:'role',width:'100',align:'center'},
			     	 {title:'所属组',field:'g_name',width:'60',align:'center'},
     				 {title:'账号',field:'username',width:'100',align:'center'},
     				 {title:'性别',field:'sex',width:'50',align:'center'},
     				 {title:'邮箱地址',field:'email',width:'150',align:'center'},
     				 {title:'电话号码',field:'tel',width:'100',align:'center'},
     				{field:'opt',title:'操作',width:100,align:'center', rowspan:2,  
                         formatter:function(value,rec){  
                         //alert(rec.id);       
                         return '<span style="color:red" mce_style="color:red"><a href="javascript:audit('+rec.id+',1)" mce_href="javascript:audit('+rec.id+',1)">修改</a> <a href="javascript:audit('+rec.id+',2)" mce_href="javascript:audit('+rec.id+',2)">删除</a></span>';  
                               
                         }  
                     } 
				]],
				toolbar:[{
					id:'btnadd',
					text:'新增用户',
					iconCls:'icon-add',
					handler:function(){
						$('#btnsave').linkbutton('enable');
						//alert('add')
					}
				},'-',{
					id:'btncut',
					text:'删除用户',
					iconCls:'icon-cut',
					handler:function(){
						$('#btnsave').linkbutton('enable');
						alert('cut')
					}
				},'-',{
					id:'btnsave',
					text:'保存',
					//disabled:true,
					iconCls:'icon-save',
					handler:function(){
						$('#btnsave').linkbutton('disable');
						alert('save')
					}
				},'-',
				{
					id:'btnsave',
					text:'搜索',
					iconCls:'icon-search',
					handler:function(){
						$('#btnsave').linkbutton('enable');
						//alert('save')
					}
				}]
			});
			var p = $('#test').datagrid('getPager');  
		    $(p).pagination({  
		        pageSize: 10,//每页显示的记录条数，默认为10  
		        pageList: [5,10,15],//可以设置每页记录条数的列表  
		        beforePageText: '第',//页数文本框前显示的汉字  
		        afterPageText: '页    共 {pages} 页',  
		        displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',  
		        /*onBeforeRefresh:function(){ 
		            $(this).pagination('loading'); 
		            alert('before refresh'); 
		            $(this).pagination('loaded'); 
		        }*/
		    });			
		});
		function resize(){
			$('#test').datagrid('resize', {
				width:700,
				height:400
			});
		}
		function getSelected(){
			var selected = $('#test').datagrid('getSelected');
			if (selected){
				alert(selected.code+":"+selected.name+":"+selected.addr+":"+selected.col4);
			}
		}
		function getSelections(){
			var ids = [];
			var rows = $('#test').datagrid('getSelections');
			for(var i=0;i<rows.length;i++){
				ids.push(rows[i].code);
			}
			alert(ids.join(':'));
		}
		function clearSelections(){
			$('#test').datagrid('clearSelections');
		}
		function selectRow(){
			$('#test').datagrid('selectRow',2);
		}
		function selectRecord(){
			$('#test').datagrid('selectRecord','002');
		}
		function unselectRow(){
			$('#test').datagrid('unselectRow',2);
		}
		function mergeCells(){
			$('#test').datagrid('mergeCells',{
				index:2,
				field:'addr',
				rowspan:2,
				colspan:2
			});
		} 
		//添加用户窗口
		function openPwd() {
	        $('#w').window({
	            title: '添加用户',
	            width: 300,
	            modal: true,
	            shadow: true,
	            closed: true,
	            height: 360,
	            resizable:false
	        });
	    }
	    //关闭添加用户窗口
	    function closePwd() {
	        $('#w').window('close');
	    }
	    $(function() {
	        openPwd();
	        $('#btnadd').click(function() {
	            $('#w').window('open');
	        });
	        $('#btnEp').click(function() {
	            serverLogin();
	        })
			$('#btnCancel').click(function(){closePwd();})		
	    });
	    function serverLogin() {
	        var $newpass = $('#txtNewPass');
	        var $rePass = $('#txtRePass');
	        $.post('/ajax/editpassword.ashx?newpass=' + $newpass.val(), function(msg) {
	            msgShow('系统提示', '恭喜，添加用户成功！');
	            $newpass.val('');
	            $rePass.val('');
	            close();
	        })           
	    }
	</script>
</head>
<body> 
	<!-- <a href="javascript:void(0)" onclick="verify()" class="easyui-linkbutton">dataGrid</a>  -->
	 	<table id="test"></table>
	 <!-- <table id="test" cellspacing="0" cellpadding="0">
		<thead>  
         <tr>  
            <th field="id" width="50" align="left"><span style="font-size:13px">ID</span></th>
            <th field="name" width="80"align="left"><span style="font-size:13px">用户名</span></th>   
            <th field="username" width="80"align="left"><span style="font-size:13px">用户登陆名</span></th>  
            <th field="sex" width="60" align="left"><span style="font-size:13px">性别</span></th>  
            <th field="email" width="140" align="left"><span style="font-size:13px">电子邮箱</span></th> 
            <th field="tel" width="140" align="left"><span style="font-size:13px">电话号码</span></th>
            <th field="opt" width="50" align="center"><span style="font-size:13px">操作</span></th>
           </tr>
         </thead>
	</table>-->	
	<div id="w" class="easyui-window" title="添加用户" collapsible="false"
			minimizable="false" maximizable="false" icon="icon-save"
			style="width: 300px; height: 360px; padding: 5px; background: #fafafa;">
			<div class="easyui-layout" fit="true">
				<div region="center" border="false" 
					style="padding: 10px; background: #fff; border: 1px solid #ccc;">
					<table cellpadding="4" style="font-size: 14px;color: #3A5FCD">
						<tr>
							<td>
								姓名：
							</td>
							<td>
								<input style="width:150px;height:25px" id="txtNewPass" type="text" value=""
									class="easyui-validatebox" required="true" 
									validtype="length[3,15]" >
							</td>
						</tr>
						<tr>
							<td>
								角色：
							</td>
							<td>
								<select id="role" class="easyui-combobox" style="width:150px;height:25px" required="true" panelHeight="auto" name="role">
									<option value="系统管理员">系统管理员</option>
									<option value="需求人员">需求人员</option>
									<option value="开发人员">开发人员</option>
									<option value="测试人员">测试人员</option>
									<option value="维护人员">维护人员</option>
								</select>
							</td>
						</tr>
						<tr>
							<td>
								所属组：
							</td>
							<td>
								<input style="width:150px;height:25px" id="txtRePass" type="text" class="easyui-validatebox"
									value="" required="true" validtype="length[3,10]" />
							</td>
						</tr>	
						<tr>
							<td>
								账号：
							</td>
							<td>
								<input style="width:150px;height:25px" id="txtRePass" type="text" class="easyui-validatebox"
									value="" required="true" validtype="length[3,10]" />
							</td>
						</tr>
						<tr>
							<td>
								性别：
							</td>
							<td>
								<select id="sex" name="sex" class="easyui-combobox" style="width:150px;height:25px" required="true" panelHeight="auto">
									<option value="男">男</option>
									<option value="女">女</option>
								</select>
							</td>
						</tr>
						<tr>
							<td>
								邮箱地址：
							</td>
							<td>
								<input style="width:150px;height:25px" id="txtRePass" type="text" class="easyui-validatebox"
									value="" required="true" validtype="email" />
							</td>
						</tr>
						<tr>
							<td>
								电话号码：
							</td>
							<td>
								<input style="width:150px;height:25px" id="txtRePass" type="text" class="easyui-validatebox"
									value="" required="true" validtype="length[3,10]" />
							</td>
						</tr>
					</table>
				</div>
				<div region="south" border="false"
					style="text-align: center; height: 30px; line-height: 30px;">
					<a id="btnEp" class="easyui-linkbutton" icon="icon-ok"
						href="javascript:void(0)">保存</a>
					<a id="btnCancel" class="easyui-linkbutton" icon="icon-cancel"
						href="javascript:void(0)"> 取消</a>
				</div>
			</div>
		</div>
</body>
</html>